#ifndef SendAudio_H
#define SendAudio_H

#include <QObject>
#include <QThread>
#include <QDebug>
#include <QTimer>

#include <QAudio>
#include <QAudioFormat>
#include <QAudioDeviceInfo>

#include <QAudioInput>
#include <QIODevice>

#include <QtNetwork/QUdpSocket>
#include <QHostAddress>

#define SENDBYTES 1024
class SendAudio: public QThread
{
    Q_OBJECT

public:
    explicit SendAudio(QObject *parent = nullptr);
    ~SendAudio();

    QUdpSocket *udpSocket;
    QHostAddress destaddr;

    QAudioInput *audioIn;
    QIODevice *inputDevice;
    QAudioFormat format;

    void init(QString ip, int srcP, int dstP, int quality, QAudioDeviceInfo devInfo);
    void mystart(int delay);
    void mystop();

    void setFormat(int quality);

    QTimer *m_timer;

    int srcPort;
    int dstPort;

public slots:
    void onReadyRead();
};

#endif // SendAudio_H
